<template>
	<table class="table table-hover">
		<thead>
			<tr>
				<th>{{ $t('runId') }}</th>
				<th>{{ $t('status') }}</th>
				<th>{{ $t('client') }}</th>
				<th>{{ $t('code.length') }}</th>
				<th>{{ $t('memory') }}</th>
				<th>{{ $t('used_time') }}</th>
				<th>{{ $t('language') }}</th>
				<th>{{ $t('submit_time') }}</th>
			</tr>
		</thead>
		<tbody>
			<tr v-if="solution">
				<td>{{ solution.id }}</td>
				<td :class="solution.resultClass">
					{{ $t('result.' + solution.resultName) }}
				</td>
				<td>{{ solution.client }}</td>
				<td>{{ solution.codeLength }}</td>
				<td>{{ solution.memoryUsed }}</td>
				<td>{{ solution.timeUsed }}</td>
				<td>{{ solution.languageName }}</td>
				<td>{{ solution.createTime }}</td>
			</tr>
		</tbody>
	</table>


	<template v-if="solution">
		<div class="code">
			<pre>{{ solution.code }}</pre>
		</div>


		<div class="message" v-if="solution.message">
			<textarea style="width: 100%;" disabled="true" v-model="solution.message"></textarea>
		</div>
	</template>
</template>



<script type="module">
import {ConfigService, SolutionService, StatusService} from '@/common/common.object'

export default {
	data() {
		return {
			solution: null,
		};
	},
	components: {
	},
	created() {
		const langPromise = ConfigService.getLanguageAndProcess();
		const solutionId = this.$route.params.id || this.$route.params.solutionId;

		SolutionService.get(solutionId, this.$route.params.contestId).then(result => {
			langPromise.then(langMapping => {
				SolutionService.process(result, langMapping);

				this.solution = StatusService.process(result);
			});
		});
	},
	methods: {
	}
};
</script>


<style scoped>
table {
	width: 100%;
}

table>thead>tr>th,
table>tbody>tr>td {
	padding: 0.75rem;
	text-align: left;
}


table>tbody>tr>td {
	margin: 0;
	border: none;
	border-top: 2px solid #ddd;
}


pre {
	overflow: auto;
	display: block;
	padding: 9.5px;
	margin: 0 0 10px;
	font-size: 16px;
	line-height: 1.42857143;
	color: #333;
	word-break: break-all;
	word-wrap: break-word;
	background-color: #f5f5f5;
	border: 1px solid #ccc;
}
</style>
